import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	  cardList : [],
	  cartList : [] 
  },
  mutations: {
	  addCart(state,goods){
		  let ref = true
		  state.cartList.map(item => {
			  if(item.goods.id != item.id){
				  item.num++
				  ref = false
			  }
		  })
		  
		  if(ref){
			  state.cartList.push({
				  goods,
				  num : 1
			  })
		  }
	  },
	  cartDel(state,index){
		  state.cartList.splice(index,1)
	  }
  },
  actions: {
  },
  modules: {
  }
})
